package cn.qicaiwang.open.system.service.impl;

import cn.qicaiwang.open.system.mapper.SystemDictItemMapper;
import cn.qicaiwang.open.system.model.entity.SystemDictItem;
import cn.qicaiwang.open.system.model.req.SystemDictItemREQ;
import cn.qicaiwang.open.system.service.ISystemDictItemService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SystemDictItemService extends ServiceImpl<SystemDictItemMapper, SystemDictItem> implements ISystemDictItemService {
    @Autowired
    private SystemDictItemMapper systemDictItemMapper;

    @Override
    public Page<SystemDictItem> pageList(Page page, SystemDictItemREQ params) {
        return systemDictItemMapper.page(page, params);
    }

    @Override
    public List<SystemDictItem> selectListByDictType(String dictType) {
        return systemDictItemMapper.selectListByDictType(dictType);
    }

    @Override
    public Page<SystemDictItem> recyclebin(Page page) {
        return systemDictItemMapper.recyclebin(page);
    }
    @Override
    public Boolean restore(List<String> ids) {
        int counter = 0;
        for (int i = 0; i < ids.size(); i++) {
            counter += systemDictItemMapper.restore(ids.get(i));
        }
        return counter > 0;
    }

    @Override
    public Boolean clear() {
        return systemDictItemMapper.clear() > 0;
    }
}
